<template>
	<view class="content">
		<view class="text">
			<u-textarea v-model="introduce" :cursorSpacing="100" :height="165" :maxlength="50" placeholder="请输入内容"
				count></u-textarea>
		</view>
		<view class="adding" @click="saveAbout">
			保存
		</view>
		<ELM ref="elm" :msg="tipMsg" :isConfirm="isConfirm" @confirm="confirm"></ELM>
	</view>
</template>
<script>
	import {
		updateUserInfo
	} from '@/common/api.js';
	import ELM from '@/components/elm-toast/index.vue';
	export default {
		data() {
			return {

				type: 0,
				tipMsg: '',
				isConfirm: false,
				introduce: ''
			}
		},
		components: {
			ELM
		},
		onLoad(option) {
			console.log(option);
			uni.setNavigationBarTitle({
				title: "自我介绍"
			})
			this.introduce = option.introduce;

		},
		methods: {
			saveAbout() {

				if (this.introduce.length < 10) {
					this.tipMsg = "内容不能少于10个字";
					this.$refs.elm.showDialog();
					return false;
				}

				uni.showLoading({
					title: '保存中...'
				})
				updateUserInfo({
					userId: this.vuex_userid,
					openId: this.vuex_openid,
					token: this.vuex_token,
					introduce: this.introduce,
				}).then(res => {
					uni.hideLoading();
					this.isConfirm = true;
					this.tipMsg = "编辑成功";
					this.$refs.elm.showDialog();
				}).catch({

				})

			},
			confirm() {
				this.isConfirm = false;
				uni.navigateBack({
					delta: 1
				})
			},
		}
	}
</script>

<style lang="less">
	page {

		background-color: #F4F5F9;
	}

	.content {
		width: 100%;
		height: 100%;
	}

	.text {
		width: 100%;
		height: 365rpx;
		background: #ffffff;
		border-top: 1rpx solid #eee;
	}

	.adding {
		width: 614rpx;
		height: 84rpx;
		background: linear-gradient(86deg, #C2D2F9 0%, #C5C2F3 100%);
		border-radius: 42rpx 42rpx 42rpx 42rpx;
		font-size: 28rpx;
		font-family: 'PingFang SC-Regular, PingFang SC';
		font-weight: 400;
		color: #415C9E;
		line-height: 84rpx;
		position: fixed;
		bottom: 54rpx;
		left: 68rpx;
		text-align: center;
	}
</style>